<template>
	<view class="container-page">
		<!-- #ifdef APP -->
		<u-navbar title="认证中心" :autoBack="true" :placeholder="true">></u-navbar>
		<!-- #endif -->
		<view class="container" v-if="userInfo">
			<view class="header">
				<view class="title">真人认证</view>
				<view class="subtitle">完成认证只需要2分钟</view>
			</view>
			<view class="benefits">
				<view class="benefit-item">
					<view class="dot"></view>
					<text style="font-size: 28rpx;">专属认证标识，优先推荐</text>
				</view>
				<view class="benefit-item">
					<view class="dot"></view>
					<text style="font-size: 28rpx;">认证提示，交友更放心</text>
				</view>
			</view>
			<view class="user-box">
				<image class="user-left" :src="$OssUrl(userInfo.avatar)" mode="aspectFill" />
				<view class="user-right">
					<view class="user-info">
						<text class="username">{{userInfo.nickname}}</text>
						<image src="/static/common/icon_user.png" class="icon_user" />
					</view>
					<view class="warning-text" v-if="userInfo.is_auth==2">
						{{userInfo.auth.check_reason}}
						<!-- 请勿出具虚假转借他人号，如账号用于违法行为，您将承担法律责任 -->
					</view>
				</view>
			</view>
			<view class="submit-section">
				<button class="submit-btn" v-if="userInfo.is_auth==0">审核中</button>
				<button class="submit-btn" v-if="userInfo.is_auth==1" @click="cancelAuth">取消认证</button>
				<button class="submit-btn" @click="handleSubmit" v-if="userInfo.is_auth==2">前往修改</button>
				<button class="submit-btn" @click="handleSubmit" v-if="userInfo.is_auth==3">立即认证</button>
			</view>
		</view>
		<view style="height: 20rpx;"></view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: null
			}
		},
		onShow(options) {
			this.getUserInfo()
		},
		methods: {
			getUserInfo() {
				this.$Api['user'].getUserInfo().then(res => {
					this.userInfo = res.data
				})
			},
			cancelAuth() {
				this.$Api['user'].updateUserInfo({
					is_auth: 3
				}).then(res => {
					this.$Toast('取消认证成功')
					this.getUserInfo()
				})
			},
			handleSubmit() {
				this.$Tips('/pages/authentication/start-authentication')
			}
		}
	}
</script>
<style lang="scss" scoped>
	.container-page {
		width: 100%;
		min-height: 100vh;
		background-color: #f7f8fa;
		position: relative;

		.container {
			margin: 20rpx 34rpx;
			padding: 38rpx 40rpx 42rpx;
			box-shadow: 0rpx 4rpx 32rpx 0rpx #FFF0FD;
			border-radius: 32rpx;
			background: linear-gradient(180deg, #FFDAF5 0%, #FFFFFF 50%);
			
			.header {
				display: flex;
				align-items: center;
				margin-bottom: 44rpx;

				.title {
					font-size: 32rpx;
					font-weight: bold;
					color: #333333;
				}

				.subtitle {
					font-size: 22rpx;
					padding: 4rpx 20rpx;
					color: #F169F6;
					background: #FEECFF;
					border-radius: 200rpx;
					margin-left: 10rpx;
					align-items: center;
					height: 32rpx;
				}
			}

			.benefits {
				margin-bottom: 48rpx;

				.benefit-item {
					display: flex;
					align-items: center;
					margin-bottom: 24rpx;

					.dot {
						width: 12rpx;
						height: 12rpx;
						background: #F169F6;
						border-radius: 50%;
					}
				}

				.benefit-item:last-child {
					margin-bottom: 0;
				}

				.benefit-item text {
					margin-left: 16rpx;
					font-size: 28rpx;
					color: #9A9A9A;
				}
			}

			.user-box {
				display: flex;
				align-items: center;

				.user-left {
					width: 84rpx;
					height: 84rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.user-right {

					.user-info {
						display: flex;
						align-items: center;

						.username {
							font-size: 32rpx;
							color: #333333;
							font-weight: bold;
							margin-right: 12rpx;
						}

						.icon_user {
							width: 32rpx;
							height: 32rpx;
						}
					}

					.warning-text {
						font-size: 24rpx;
						color: #FF6B6B;
						line-height: 32rpx;
						margin-top: 14rpx;
						width: 500rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

				}
			}

			.submit-section {
				margin: 46rpx auto 0;

				.submit-btn {
					width: 628rpx;
					height: 88rpx;
					font-weight: bold;
					font-size: 30rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 88rpx;
					background: linear-gradient(135deg, #FE93BF 0%, #A27AFF 100%);
					box-shadow: 0rpx 4rpx 10rpx 0rpx #FDC4FF;
					border-radius: 44rpx;
				}
			}
		}
	}
</style>